// 页面的数据源

let data = {
  sysSizeList: [],
};

let prepareTable = function(self){
  let tableTitle = [
    {
      type: 'index',
      width: 55,
      align: 'center',
      fixed: 'left'
    },
    {
      title: '类型',
      key: 'type',
      align: 'center',
      minWidth:150,
      render: (h, params) => {
        return ('div', self.sizeTypes.map(function (item) {
          if (params.row.type == item.value) {
            return item.name;
          }
        }));
      }
    },
    {
      title: '名称',
      key: 'name',
      align: 'center',
      minWidth:100
    },
    {
      title: '顺序',
      key: 'sequence',
      align: 'center',
      minWidth:50,
    },
  ];
  if(self.$authority('PRODUCT-4-205')){
    tableTitle.push({
      title: '操作',
      key: 'action',
      fixed: self.$yMobile()?"none":'right',
      minWidth:200,
      render: (h, params) => {
        return h('div', [
          h('Button', {
            props: {type: 'primary', size: 'small', icon: "md-create"},
            style: {marginRight: '10px'},
            on: {
              click: () => {
                self.showModifySysSize(params.index);
              }
            }
          }, '编辑'),
          h('Button', {
            props: {type: 'error', size: 'small', icon: "md-trash"},
            style: {marginRight: '10px', },
            on: {
              click: () => {
                self.showDelSysSizeModal(params.index);
              }
            }
          }, '删除')
        ]);
      },
      align: 'center'
    });
  }
  return tableTitle;
};

// 页码相关
let page = {
  total: 1,
  startIndex: 0,
  stepNumber: 20,
  currentPage: 1
};

let status = {
  //各种操作时的 modal
  modalAction: {
    isShow: false,
    isAdd:true,
    isLoading: false,
    content: '',
    sysSize:{
      id:'',
      name:''
    }
  },
  modalModify: {
    isShow: false,
    isLoading: false
  },
  vlidation: {
    name: [
      {required: true, message: '名称不能为空', trigger: 'blur'}
    ],
    type: [
      {required: true, type: 'number', message: '请选择类型', trigger: 'change'}
    ],
    sequence: [
      {type: 'number', message: '请输入数字', trigger: 'blur'}
    ]
  }
};

// 和网络交互相关的参数
let params = {
  type:-1,
  paramSysSize:{
    id:'',
    type:-1,
    name:'',
    sequence:0
  }
}

export  default  {
  tPage: page,
  tStatus: status,
  tParam: params,
  tData: data,
  tTable: prepareTable
};
